using Holoville.HOTween;
using Holoville.HOTween.Core;
using UnityEngine;

public class EndPVPReputationProgress : MonoBehaviour
{
	public delegate void OnComplete();

	[SerializeField]
	private UISprite progresBar;

	[SerializeField]
	private UISprite AddProgresBar;

	[SerializeField]
	private UILabel progreslabel;

	private Vector3 scale;

	private int myRespect;

	private int addReputation;

	private int maxReputationFromThisMap;

	private OnComplete onComplete;

	public int iScaleRespect;

	private float percent
	{
		get
		{
			return progresBar.fillAmount;
		}
		set
		{
			progresBar.fillAmount = value;
			if (progreslabel != null)
			{
				progreslabel.text = (int)(100f * value) + "%";
			}
		}
	}

	public void Init(int myRespect, int maxReputationFromThisMap)
	{
		scale = base.transform.localScale;
		this.myRespect = myRespect;
		this.maxReputationFromThisMap = maxReputationFromThisMap;
		float num = (float)myRespect / (float)maxReputationFromThisMap;
		percent = num;
	}

	public void AddFillAmount(int addReputation, OnComplete onComplete)
	{
		this.addReputation = addReputation;
		this.onComplete = onComplete;
		Invoke("AddFillScale", 2f);
	}

	private void AddFillScale()
	{
		HOTween.Init();
		float num = (float)myRespect / (float)maxReputationFromThisMap;
		int curRespect = myRespect + addReputation;
		if (curRespect > maxReputationFromThisMap)
		{
			curRespect = maxReputationFromThisMap;
		}
		iScaleRespect = myRespect;
		if (addReputation != 0)
		{
			HOTween.To(base.transform, 0.5f, new TweenParms().Prop("localScale", scale * 1.1f).OnComplete((TweenDelegate.TweenCallback)delegate
			{
				HOTween.To(this, 1.5f, new TweenParms().Prop("iScaleRespect", curRespect).Ease(EaseType.EaseOutSine).OnUpdate((TweenDelegate.TweenCallback)delegate
				{
					percent = (float)iScaleRespect / (float)maxReputationFromThisMap;
					if (progreslabel != null && progreslabel.transform.localScale.x < 1.5f)
					{
						progreslabel.transform.localScale += Vector3.one * 0.015f;
					}
				})
					.OnComplete((TweenDelegate.TweenCallback)delegate
					{
						HOTween.To(progreslabel.transform, 0.2f, new TweenParms().Prop("localScale", Vector3.one).OnComplete((TweenDelegate.TweenCallback)delegate
						{
						}));
						HOTween.To(base.transform.transform, 0.2f, new TweenParms().Prop("localScale", scale).OnComplete((TweenDelegate.TweenCallback)delegate
						{
							onComplete();
						}));
						myRespect = iScaleRespect;
					}));
			}));
		}
		else
		{
			onComplete();
		}
	}
}
